<?php
 header("Content-type:text/html;charset=utf-8");
 
 $name = $_POST["userName"];
 $pwd = $_POST["userPswd"];
 
 // 1.创建链接  
 $conn = mysql_connect("localhost","root","root");

 // 2.选择库名
 mysql_select_db("kv");
  
 // 3.操作
 $result = mysql_query("select * from usermsg where userName='$name'",$conn);
  
 // var_dump("select * from userMsg where userName='$name' And userPwd='$pwd'");
  
 if(mysql_num_rows($result) == 1){
  echo 1;
 }else{
  echo 0;
 $account = mysql_query("insert into usermsg  (userName, userPswd) values ('$name', '$pwd')",$conn);
 if(mysql_num_rows($account) == 1){
     echo 1;
 }else{
     echo 0;
  }
 }
  //  var_dump("insert into usermsg  (userName, userPswd) values ('$name', '$pwd')" );
   // 0 注册成功
   // 1 是已注册

 // 4.关闭数据库
 mysql_close($conn);
?>